/**
 * Created by congzhang on 17/11/6.
 */


// var mongoose = require("mongoose");
//
// mongoose.connect("mongodb://root:F8a4C7c2Cdd013ACDE@192.168.10.55", {useMongoClient: true});
//
// var connection=mongoose.connection;
//
// connection.on("err", function (err) {
//     console.log("数据库连接失败: " + err)
// });
// connection.on("open", function () {
//     console.log("数据库连接成功")
// });




var mongoose = require('mongoose');
mongoose.Promise = global.Promise;
var DB_URL = 'mongodb://hezhongwiki:123@192.168.10.55/hezhongwiki';

/**
 * 连接
 */
mongoose.connect(DB_URL, {useMongoClient: true});

/**
 * 连接成功
 */
mongoose.connection.on('connected', function () {
    console.log('Mongoose connection open to ' + DB_URL);
});

/**
 * 连接异常
 */
mongoose.connection.on('error',function (err) {
    console.log('Mongoose connection error: ' + err);
});

/**
 * 连接断开
 */
mongoose.connection.on('disconnected', function () {
    console.log('Mongoose connection disconnected');
});


module.exports = mongoose;